#include <stdio.h>
#include <Windows.h>
#include "Delegate.h"
typedef struct{
	int top;
	int left;
	int width;
	int height;
}Rect;
class A
{
	char*str;
public:
	A():str("我是类A的对象"){}
	void *ShowMsg(int M,Rect rect,int N,char ch,int iNum)
	{
		printf("M=%d;left=%d;top=%d;width=%d;height=%d;N=%d;ch=%c;iNum=%d\n",M,rect.left,rect.top,rect.width,rect.height,N,ch,iNum);
		printf("%s\n",str);
		return 0;
	}
	void HandleEvent(int M,Rect rect,int N,char ch,int iNum)
	{
		printf("M=%d;left=%d;top=%d;width=%d;height=%d;N=%d;ch=%c;iNum=%d\n",M,rect.left,rect.top,rect.width,rect.height,N,ch,iNum);
		printf("我是HandleEvent\n");
	}
};
class B
{
public:	
	B(){}
	void 引发事件(){
		Rect rect={0,0,500,500};
		委托(500,rect,300,'G',200);
	}
	Delegate(int,委托类型,(int M,Rect rect,int N,char ch,int iNum));
	委托类型 委托;
};
int main()
{
	B b;A a;
	b.委托+=EventHandler(&a,&A::ShowMsg);
	b.委托+=EventHandler(&a,&A::HandleEvent);
	b.引发事件();
	system("pause");
}
